<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage = "error.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<c:if test="${!user.isLoggedIn() || user.isInactive() || !user.isAdmin()}">
	<c:redirect url="error.jsp"/>
</c:if>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Administration</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/Resources/Styles/back.css">
    <script src="${pageContext.request.contextPath}/Resources/Scripts/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/Scripts/script.js"></script>
    <script src="${pageContext.request.contextPath}/Resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
	<c:if test="${!empty errorMessage}">
		<strong>Oooops... folgender Fehler ist aufgetreten:</strong>			
		<p>${errorMessage}</p>
		<p>Bitte loggen Sie sich ein!</p>
		<a href="login.html">Zur Login Seite wechseln</a>
	</c:if>
	<c:if test="${empty errorMessage}">
    <form action="UserListController" name="appform" method="post" id="target" class="form-horizontal">
        <div class="item-active">
            <div class="container">
                <div class="panel active">
                    <ul class="nav nav-tabs nav-pills" id="myTab">
                        <li class=""> <a class="cameraFilter" href="#cameraFilter" data-toggle="tab">Cameras</a>
	                    <li class="active dropdown">
	                         <a class="dropdown-toggle" data-toggle="dropdown">Management<span class="caret"></span></a>
	                         <ul class="dropdown-menu" role="menu">
	                            <li><a class="addUser" href="#addUser" data-toggle="tab">Add New user</a></li>
	                            <li><a class="" href="#ShowUsers" data-toggle="tab">Show User List</a></li>
	                            <li><a class="editCameras" href="#EditCameras" data-toggle="tab">Camera Management</a></li>
	                         </ul>
	                    </li>
                        <li class=""> <a href="#" data-toggle="tab">About</a>
                        <li class="pull-right"> <a class="logout" href="#" data-toggle="tab">Logout</a>
                    </ul>
                    <br>
                    <div class="tab-content" style="width: 90%; margin-left: 60px">
                        <div class="row">
                            <fieldset>
                                <div class="form-group">
                                    <table class="table borderless">
                                        <thead>
                                            <tr>
                                                <th>Username</th>
                                                <th>Full name</th>
                                                <th>Location</th>
                                                <th>Admin</th>
                                                <th>Inactive</th>
                                                <th>Edit</th>
                                                <th>Delete</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <c:forEach var="varUser" items="${UserList}">
                                                <tr>
                                                   <td><c:out value="${varUser.getUsername()}" /></td>
                                                    <td><c:out value="${varUser.getFullname()}" /></td>
                                                    <td><c:out value="${varUser.getLocation()}" /></td>
                                                    <td><c:out value="${varUser.isAdmin()}" /></td>
                                                    <td><c:out value="${varUser.isInactive()}" /></td>
                                                    <td><button name="btnEdituser" value="${varUser.getUsername()}" type="submit" class="btn btn-primary">Edit</button>                                      
                                                    <td><button name="btnDelUser" value="${varUser.getUsername()}" type="submit" class="btn btn-primary">Delete</button>
                                                </tr>
                                            </c:forEach>
                                        </tbody>
                                    </table>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
   </c:if>
</body>
</html>
